<?php

namespace app\service;

use app\exception\ErrnoPlus;
use app\model\UrlSelectorModel;
use share\exception\ApiException;
use share\service\BaseModelService;

class UrlSelectorService extends BaseModelService
{

    const SELECTOR_TYPE_SCORE_OF_CLIENT = 1;
    const SELECTOR_TYPE_SCORE_OF_VENDOR = 0b10;
    const SELECTOR_TYPE_SCORE_OF_PACKAGE = 0b100;
    const SELECTOR_TYPE_SCORE_OF_VERSION = 0b1000;
    const SELECTOR_TYPE_SCORE_OF_IP = 0b10000;


    const SELECTOR_TYPE_SCORE_OF_DID = 0b1000000;


    public static function getScoreByType($type){
        $type = strtolower(trim($type));
        if($type == "ip"){
            return self::SELECTOR_TYPE_SCORE_OF_IP;
        }
        else if($type == "vendor"){
            return self::SELECTOR_TYPE_SCORE_OF_VENDOR;
        }
        else if($type == "package"){
            return self::SELECTOR_TYPE_SCORE_OF_PACKAGE;
        }
        else if($type == "version"){
            return self::SELECTOR_TYPE_SCORE_OF_VERSION;
        }
        else if($type == "client"){
            return self::SELECTOR_TYPE_SCORE_OF_CLIENT;
        }
        else if($type == "did"){
            return self::SELECTOR_TYPE_SCORE_OF_DID;
        }
        return 0;
    }

    public static function getModel()
    {
        return new UrlSelectorModel;
    }
}
   
